package cn.org.mrliu.ssm.qq;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.org.mrliu.ssm.model.Message;
import cn.org.mrliu.ssm.service.MessageService;

@Component
public class QQMessageInterceptorImpl implements QQMessageInterceptor {
	@Resource
	private MessageService messageService;
	@Override
	public boolean before(QQMessage qqMessage) {
		System.out.println("before...");
		return true;
	}

	@Override
	public void after(QQMessage qqMessage,boolean success) {
		System.out.println("after...");
		Message model = new Message();
		model.setContent(qqMessage.getMessage());
		try {
			System.out.println(messageService);
			messageService.saveModel(model);
			System.out.println("QQ消息保存成功....");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void success(QQMessage qqMessage) {
		System.out.println("success...");
	}

	@Override
	public void failure(QQMessage qqMessage, Exception exception) {
		System.out.println("failure...");
	}

}
